package org.sais.eswn.card;

import java.awt.Color;

public class Card {

    public static final int COLOR_WHITE = 0;
    public static final int COLOR_BLUE = 1;
    public static final int COLOR_BLACK = 2;
    public static final int COLOR_RED = 3;
    public static final int COLOR_GREEN = 4;
    public static final int CARDTYPE_SPELL = 0;
    public static final int CARDTYPE_EVENT = 1;
    public String no;
    public String name;
    public CardText text;

    public Color getDisplayColor() {
        switch (getColor()) {
            case COLOR_WHITE:
                return new Color(240, 240, 240);
            case COLOR_BLUE:
                return new Color(210, 210, 255);
            case COLOR_BLACK:
                return new Color(190, 190, 190);
            case COLOR_RED:
                return new Color(255, 210, 210);
            case COLOR_GREEN:
                return new Color(210, 255, 210);
            default:
                return null;
        }
    }

    public int getNumber() {
        if (getType() == CARDTYPE_SPELL) {
            return Integer.parseInt(no.substring(1));
        } else {
            return Integer.parseInt(no.substring(2));
        }
    }

    public int getColor() {
        switch (no.charAt(0)) {
            case 'W':
                return COLOR_WHITE;
            case 'U':
                return COLOR_BLUE;
            case 'B':
                return COLOR_BLACK;
            case 'R':
                return COLOR_RED;
            case 'G':
                return COLOR_GREEN;
            case 'V':
                switch (no.charAt(1)) {
                    case 'W':
                        return COLOR_WHITE;
                    case 'U':
                        return COLOR_BLUE;
                    case 'B':
                        return COLOR_BLACK;
                    case 'R':
                        return COLOR_RED;
                    case 'G':
                        return COLOR_GREEN;
                }
        }
        return -1;
    }

    public int getType() {
        return no.charAt(0) == 'V' ? CARDTYPE_EVENT : CARDTYPE_SPELL;
    }
}
